<template>
  <div>
    <van-tabbar
      v-model="active"
      active-color="#ff4500"
      inactive-color="#000"
      @change="onChange"
    >
      <van-tabbar-item icon="wap-home-o">首页</van-tabbar-item>
      <van-tabbar-item icon="apps-o">分类</van-tabbar-item>
      <van-tabbar-item icon="cart-o">购物车</van-tabbar-item>
      <van-tabbar-item icon="contact">会员</van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  name: "pageTabs",
  props: {
    childActive: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      active: 0,
    };
  },
  mounted() {
    this.active = this.childActive;
  },
  methods: {
    onChange(index) {
      if (index === 0) {
        this.$router.push("/index");
      }
      if (index === 1) {
        this.$router.push("/classify");
      }
      if (index === 2) {
        this.$router.push("/shoppingCart");
      }
      if (index === 3) {
        this.$router.push("/vip");
      }
    },
  },
};
</script>
